﻿namespace Nop.Plugin.Payments.UsaEpay.Controllers
{
    #region

    using FluentValidation;

    using Nop.Plugin.Payments.UsaEpay.Models;
    using Nop.Services.Localization;
    using Nop.Web.Framework.Validators;

    #endregion

    /// <summary>
    ///     The payment info validator.
    /// </summary>
    public class PaymentInfoValidator : AbstractValidator<PaymentInfoModel>
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="PaymentInfoValidator"/> class.
        /// </summary>
        /// <param name="localizationService">
        /// The localization service.
        /// </param>
        public PaymentInfoValidator(ILocalizationService localizationService)
        {
            this.RuleFor(x => x.CardholderName).NotEmpty().WithMessage(localizationService.GetResource("Payment.CardholderName.Required"));
            this.RuleFor(x => x.CardNumber).IsCreditCard().WithMessage(localizationService.GetResource("Payment.CardNumber.Wrong"));
            this.RuleFor(x => x.CardCode).Matches(@"^[0-9]{3,4}$").WithMessage(localizationService.GetResource("Payment.CardCode.Wrong"));
            this.RuleFor(x => x.ExpireMonth).NotEmpty().WithMessage(localizationService.GetResource("Payment.ExpireMonth.Required"));
            this.RuleFor(x => x.ExpireYear).NotEmpty().WithMessage(localizationService.GetResource("Payment.ExpireYear.Required"));
        }

        #endregion
    }
}